package com.sgb.businessmodule.view.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.bumptech.glide.RequestManager;
import com.sgb.businessmodule.BR;
import com.sgb.businessmodule.R;
import com.sgb.businessmodule.databinding.ItemHomeTabViewBinding;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.ResolutionUtil;
import com.swgk.core.view.countmenu.CountMenuEntity;

import java.util.List;

public class BusinessTabAdapter extends BaseRecycleAdapter<CountMenuEntity> {
    private String currentName = "";

    public BusinessTabAdapter(Context context, List<CountMenuEntity> data) {
        super(context, R.layout.item_home_tab_view, data);
    }

    @Override
    public void convert(ItemViewHolder holder, CountMenuEntity entity) {
        ItemHomeTabViewBinding binding = (ItemHomeTabViewBinding) holder.getmBinding();
        if (currentName.equals(entity.getName())) {
            binding.tvTabItem.setText(entity.getName());
            entity.setSelect(true);
        } else {
            binding.tvTabItem.setText(entity.getName());
            entity.setSelect(false);
        }
        holder.setBinding(BR.viewModel, entity);
        int width = ResolutionUtil.getScreenWidth(context);
        ViewGroup.LayoutParams layoutParams = holder.itemView.getLayoutParams();
        layoutParams.width = width / 5;
        holder.itemView.setLayoutParams(layoutParams);
    }

    public void setCurrentSelected(String name) {
        this.currentName = name;
        notifyDataSetChanged();
    }

}
